package Control;

import qwqw.ClientConsole;
import GUI.IP;
import GUI.ScreenManager;
/**
 * Controls the instance of IP
 * This class sends thr ip address to the server 
 * @author Aviat
 *
 */ 
public class IPControl {
	final public static int DEFAULT_PORT = 2222;
	private ClientConsole cc;
	private IP IPPanel;
	
	/**
	 * the constructor
	 */
	public IPControl(){
		IPPanel = new IP();
	}

	/**
	 * 
	 * @return IPPanel
	 */
	public IP getIPPanel(){
		return IPPanel;
	}
	
	/**
	 * 
	 * @return String with the ip address entered in the TextArea
	 */
	public String ip_entered(){
		return IPPanel.getTextArea_ip().getText();
	}
	
	/**
	 * send to the server the ip address and default fort 
	 * for connection
	 * @param ip
	 * @return boolean
	 */
	public boolean makeConnection(String ip){
		cc=ScreenManager.getConnection(ip, DEFAULT_PORT);
		if(cc.cclient==null){
			return false;
		}
		return true;
	
			
	}
}
